package com.woniu.adapter;

import com.woniu.outlet.dao.CompanyTaskMapper;
import com.woniu.outlet.po.CompanyTask;
import com.woniu.outlet.po.CompanyTaskExample;
import com.woniu.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Component
@Transactional
public class CompanyTaskAdapter {

    @Autowired
    private CompanyTaskMapper companyTaskMapper;

    //这个是客户申请办理业务的
    public int addtask(CompanyTask companyTask){
        int insert = companyTaskMapper.insert(companyTask);
        return insert;
    }


    //客户经理查看自己任务信息
    public List<CompanyTask> findmytask(Integer workerid){
        CompanyTaskExample example = new CompanyTaskExample();
        CompanyTaskExample.Criteria criteria = example.createCriteria();
        criteria.andCompanytaskStatusEqualTo(0);
        criteria.andWorkeridEqualTo(workerid);
        List<CompanyTask> companyTasks = companyTaskMapper.selectByExample(example);
        return companyTasks;
    }

    //客户经理来处理客户的业务信息，处理完成之后，还要添加业务表的一条信息
    public int handletask(Integer companytaskId,Integer workerid,Integer companyid,Integer companytaskType){
        //修改客户的任务状态信息
        int updatestatus = companyTaskMapper.updatestatus(companytaskId);

        //添加一条业务信息
        int addachievement = companyTaskMapper.addachievement(workerid, companyid, companytaskType);
        return addachievement;
    }



}
